<header class="uc_head">
    <h3>我要建议</h3>
</header>

<section class="user_form">
      <dl>
            <dt>建议标题：</dt>
            <dd>
                <input name="title" type="text" pattern='required' alt='地址不能为空' class="input_text" />
                <label>地址不能为空</label>
            </dd>
        </dl>
        <dl><dt></dt>
            <dd>
              <input class="input_submit" type="submit" id="search" value="搜索" />
              <input class="input_submit" type="submit" id="showmap" value="展示地图" />
            </dd>
        </dl>
    <div id="show" style="width:200px;height:200px;"></div>
    <div id="all"  style="width:200px;height:200px; margin-top:5px;" ></div>
</section>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=6vo6wYScpSXQHfWYEbNS4G99obVXIb6x"></script>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $("#shopmap").click(function(){
        var add=$(".input_text").val();
        $.ajax({
           url:"{url:/test/jw}",
           data:"{address:add}",
           dataType:"json",
            type:"post",
            success:function(res)
            {
                var lng=res.lng;
                var lat=res.lat;
                var map = new BMap.Map("show");
                var point = new BMap.Point(lng,lat);
                map.centerAndZoom(point,12);
                var geoc = new BMap.Geocoder();

                map.addEventListener("click", function(e){
                    var pt = e.point;
                    geoc.getLocation(pt, function(rs){
                        var addComp = rs.addressComponents;
                        alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);

                    });
                });
            },
        });


    });
</script>










































